﻿// -----------------------------------------------------------------------
// <copyright file="PushApplication.cs" company="Zen Design Corp">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Zen.BlackBerry.Push.AppManagement
{
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;

	/// <summary>
	/// Represents the details and attributes of a push application.
	/// A push application refers to an application that can be installed on
	/// the device and that can accept push messages sent to it.
	/// </summary>
	public class PushApplication
	{
		/// <summary>
		/// Get or set the unique identifier for this application
		/// </summary>
		public Guid Id
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the RIM Application id.
		/// </summary>
		/// <value>
		/// For a push application of type "Public Push" or "Public+Enterprise Push",
		/// this will be assigned by a RIM administrator.
		/// For a push application of type "Enterprise Push", this can be any
		/// random unique value.
		/// </value>
		public string RimApplicationId
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the name.
		/// </summary>
		/// <value>The name.</value>
		public string Name
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the description.
		/// </summary>
		/// <value>The description.</value>
		public string Description
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the created date.
		/// </summary>
		/// <value>The created date.</value>
		public DateTime CreatedDate
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the default push live time.
		/// </summary>
		/// <value>The default push live time.</value>
		public TimeSpan DefaultPushLiveTime
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the enterprise notify URL.
		/// </summary>
		/// <value>The enterprise notify URL.</value>
		public string EnterpriseNotifyUrl
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the enterprise password.
		/// </summary>
		/// <value>The enterprise password.</value>
		public string EnterprisePassword
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the expiry date.
		/// </summary>
		/// <value>The expiry date.</value>
		public DateTime? ExpiryDate
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the maximum daily pushes.
		/// </summary>
		/// <value>The maximum daily pushes.</value>
		public int MaximumDailyPushes
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the modified by.
		/// </summary>
		/// <value>The modified by.</value>
		public string ModifiedBy
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the modified date.
		/// </summary>
		/// <value>The modified date.</value>
		public DateTime ModifiedDate
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the public notify URL.
		/// </summary>
		/// <value>The public notify URL.</value>
		public string PublicNotifyUrl
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the public password.
		/// </summary>
		/// <value>The public password.</value>
		public string PublicPassword
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the push port.
		/// </summary>
		/// <value>The push port.</value>
		public int PushPort
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the service level.
		/// </summary>
		/// <value>The service level.</value>
		public PushApplicationServiceLevel ServiceLevel
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the start date.
		/// </summary>
		/// <value>The start date.</value>
		public DateTime StartDate
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the status.
		/// </summary>
		/// <value>The status.</value>
		public PushApplicationStatus Status
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the type.
		/// </summary>
		/// <value>The type.</value>
		public PushApplicationType Type
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the name of the user.
		/// </summary>
		/// <value>The name of the user.</value>
		public string UserName
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the version.
		/// </summary>
		/// <value>The version.</value>
		public string Version
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets a value indicating whether this instance is application reliable.
		/// </summary>
		/// <value>
		/// 	<c>true</c> if this instance is application reliable; otherwise, <c>false</c>.
		/// </value>
		public bool IsApplicationReliable
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets a value indicating whether [auto delete requests].
		/// </summary>
		/// <value><c>true</c> if [auto delete requests]; otherwise, <c>false</c>.</value>
		public bool AutoDeleteRequests
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets a value indicating whether [bypass subscriptions].
		/// </summary>
		/// <value><c>true</c> if [bypass subscriptions]; otherwise, <c>false</c>.</value>
		public bool BypassSubscriptions
		{
			get;
			set;
		}

		/// <summary>
		/// Gets a value indicating whether this instance is expired.
		/// </summary>
		/// <value>
		/// 	<c>true</c> if this instance is expired; otherwise, <c>false</c>.
		/// </value>
		public bool IsExpired
		{
			get
			{
				return ExpiryDate.HasValue && DateTime.UtcNow > ExpiryDate;
			}
		}

		/// <summary>
		/// Gets or sets a value indicating whether this instance is last notification enabled.
		/// </summary>
		/// <value>
		/// 	<c>true</c> if this instance is last notification enabled; otherwise, <c>false</c>.
		/// </value>
		public bool IsLastNotificationEnabled
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets a value indicating whether this instance is store push requests.
		/// </summary>
		/// <value>
		/// 	<c>true</c> if this instance is store push requests; otherwise, <c>false</c>.
		/// </value>
		public bool IsStorePushRequests
		{
			get;
			set;
		}

		/// <summary>
		/// Gets a value indicating whether this instance is tracking last notification.
		/// </summary>
		/// <value>
		/// 	<c>true</c> if this instance is tracking last notification; otherwise, <c>false</c>.
		/// </value>
		public bool IsTrackingLastNotification
		{
			get
			{
				return (IsStorePushRequests && (IsLastNotificationEnabled || AutoDeleteRequests));
			}
		}
	}
}
